home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1988 / Apr 88 / Resource Forks in MacApp 4⁄4 < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.2 KB  |  66 lines  |  [TEXT/GEOL]

  1. Item    5679017                         4-April-88        17:05
  2.  
  3. From:   ROSENSTEIN1                     Rosenstein, Larry
  4.  
  5. To:     MACAPP$                         MacApp Interest List
  6.  
  7. cc:     SHEETS1                         Sheets, Steve
  8.  
  9. Sub:    Resource Forks in MacApp
  10.  
  11. MacApp always tries to save files by making a temporary copy and renaming this
  12. to the original file name only if the save succeeds.  This guarantees that the
  13. user doesn't lose the original version.
  14.  
  15. If there is not enough disk space (based on the numbers returned by
  16. DoNeedDiskSpace) to make a second copy, then MacApp will check to see if there
  17. would be enough space by deleting the original version.  If so, then MacApp
  18. will ask the user if it is OK to delete the original.  (The user can cancel and
  19. save to a different disk instead.)
  20.  
  21. You can tell MacApp never to delete the original version by setting the field
  22. TDocument.fSaveInPlace to sipNever (the default if sipAskUser).  In that case,
  23. the user will get an "out-of-disk-space" message if there is not enough space
  24. to save a copy.  You can tell MacApp to automatically save over the original
  25. version by setting it to sipAlways.  This field is only relevant if there is
  26. not enough space to make a copy, but there would be if the original was deleted
  27. first.
  28.  
  29. One of the 2 methods TDocument.SaveViaTemp and SaveInPlace will be called to do
  30. the actual save.  SaveInPlace must be overridden if you tell MacApp to keep the
  31. data or resource forks open at all times.  These methods call
  32. TDocument.MakeNewCopy, which does the actual File Manager calls.
  33.  
  34. SaveInPlace simply deletes the original file, and saves into a file with the
  35. appropriate name.  SaveViaTemp saves into a temporary file, deletes the
  36. original, and renames the temporary file to the proper name.
  37.  
  38. You will notice that for all the cases handled by MacApp automatically, the
  39. application is saving into a brand new file.  Sometimes, the original file will
  40. have been deleted already (the save in place case).  If you instruct MacApp to
  41. keep the data and/or resource fork open, then the original file will be
  42. available while the new file is being created.
  43.  
  44. Because of this, MacApp does not support a model where saving a file involves
  45. making a few changes to resources in the file and the resource fork is simply
  46. updated.  The application must be prepared to copy all the resources out of the
  47. old file and add them to the new one.
  48.  
  49. In the case of DrawShapes, the program just reads the resource in DoRead and
  50. makes a copy of the data.  DoWrite copies this data and adds it to the resource
  51. fork.  In both cases, the resource will be freed when MacApp closes the
  52. resource fork.  (When saving, closing the resource fork flushes all the
  53. resources to disk.)
  54.  
  55. The constants you mentioned are the overhead for each resource type and for the
  56. resource file in general.  These are provided in MacApp so that your
  57. DoNeedDiskSpace method can compute the number of bytes your resource fork uses.
  58.  TDocument.DoNeedDiskSpace will add kRsrcFileOverhead to the rsrcForkBytes
  59. automatically. You need to add kRsrcTypeOverhead for each distinct type you
  60. create, and kRsrcOverhead for each resource.  (This is in addition to the
  61. number of bytes in the resources themselves.)
  62.  
  63. Larry Rosenstein
  64.  
  65.  
  66.